#!/usr/local/bin/python3
# -*- coding: UTF-8 -*-
"""
@author:apple
@file:demo02.py
@time:2022/01/26
"""

import random


def test01():
    ...
    age = 23 ** 32
    opt = 32 ** 23
    print(age, opt)


def test02():
    ...
    print(random.random())
    print(random.choice([3, 4, 1, 5, 6]))


def test03():
    ...
    name = 'zhangsan'
    print(name[-1])
    # [1,3)
    print(name[1:3])
    print(name[::-1])
    # [0,len(name) - 1)
    print(name[:-1])
    print(name)

    print("name:{name}".format(name=name))
    print(f'name:{name}')
    print('name:{0}'.format(name))


def test04():
    """
    asdads
    """
    opt = 20
    """
    111111111
    """


def test05():
    ...
    # print(dir(test04))
    # for key in dir(test04):
    #     ...
    #     print("{0}:{1}".format(key,getattr(test04,key)))
    # print(getattr(test04, '__doc__'))
    name = 'lisi'
    print(help(__import__))
    print(help(dir))


def test06():
    ...
    print(ord('A'))
    print(chr(97))

    ages = [1, 2, 3]
    ages01 = ages + [1, 1, 1]
    print(ages01)


def test07():
    """
    栈: append()压入， pop()弹出
    队列:  insert(0,xxx)队头插入， pop()队尾弹出

    """
    ages = [1, 2, 3]
    print(ages.pop())
    ages.insert(0, 4)
    print(ages)


def test08():
    ...
    matrix = [[1,2,3],[4,5,6],[2,1,6]]

    result = [ item[2] for item in matrix if item[1] % 2 == 0]
    print(result)

    name = 'zhangsan'
    print([ch * 2 for ch in name])
    print({ ch:ord(ch) for ch in name})


    opt = {}
    opt = dict()
    print(type(opt))

    top = set()
    print(type(top))


def test09():
    ...
    for i in range(4, 10):
        yield i


def test10():
    ...
    per = {'name':'opt','age':21}

    if 'kop' not in per:
        print(per)

    if per.get('opt'):
        print(per)
    print(per.get('sa',100))


def test11():
    ...
    print(['10'] * 50)
    import sys
    print(sys.getrefcount(390))


def test12():
    ...
    name = 'zhangsan'
    print(name[slice(None,None,-1)])
    print(int('21'))
    bins = '110101'

    sum = 0
    for ch in bins:
        ...
        byt = ord(ch) - ord('0')
        sum = sum * 2 + byt


    print(sum)
    print(int('110101', base =2))

    print(bin(13))

if __name__ == '__main__':
    pass
    # g = test09()
    # print(type(g))
    # print(next(g))
    # print(next(g))
    # print(next(g))
    # print(next(g))
    test12()
